package com.hotel.sampleTool;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.google.appengine.api.datastore.DatastoreService;
import com.google.appengine.api.datastore.DatastoreServiceFactory;
import com.google.appengine.api.datastore.Entity;
import com.google.appengine.api.datastore.FetchOptions;
import com.google.appengine.api.datastore.PreparedQuery;
import com.google.appengine.api.datastore.Query;

public abstract class RequestSampleData {
	
	protected static DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
	
	public abstract void CreateSample();
	public abstract void CreateSample(int iteration);

	HttpServletRequest req;
	HttpServletResponse resp;

	public Boolean IsExist(String entityName)
	{
		Query q = new Query(entityName).setKeysOnly();
		PreparedQuery a = datastore.prepare(q);
		List<Entity> list = a.asList(FetchOptions.Builder.withLimit(1));
		
		if (!list.isEmpty())
			return true;
		else
			return false;
	}
}
